package genericBean;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class GenericBean<T> {

    T a;

    Type genericType;

    public GenericBean(T a) {
        this.a = a;
        this.genericType = getActualType();
    }

    private Type getActualType() {
        Type type = getClass().getGenericSuperclass();
        if (type instanceof ParameterizedType) {
            ParameterizedType parameterizedType = (ParameterizedType) genericType;
            Type actualType = parameterizedType.getActualTypeArguments()[0];
            return actualType;
        }
        return null;
    }

}
